﻿module UI {

    language Filteration {
        syntax Main = f:Filter =>
            f;

        syntax Filter = s:CharacTap sa:Samples sl:Samp+=>
            { Simulation => s, Samples => {sa}, Sequence=>{valuesof(sl)} }
            |
            s:CharacTap=>
            Simulation {s};
        
        syntax CharacTap = 
            c:Charac ':' "Taps:" t:CommaList(Coefficient) =>
            {Characteristic  {c}, Taps  {valuesof(t)} }
            |
            c:BandChar ':' "Taps 1:" t1:CommaList(Coefficient) "Taps 2:" t2:CommaList(Coefficient) =>
            {Characteristic {c}, Taps1 {valuesof(t1)}, Taps2{valuesof(t2)}};
        
        @{Classification["Keyword"]}
        token Charac = 
            ("Low Pass"
            |
            "High Pass");
            
        token BandChar = 
            ("Band Pass"
            |
            "Band Reject");
            
        token Digit = 
            "0".."9";
        
        syntax CommaList(Element) = 
            n:Element => {n}
            |
            list:CommaList(Element)"," n:Element =>
            [valuesof(list), n];
        
        token Coefficient:Double = '-'?Natural
            |
            '-'?Digit* '.' Natural
            |
            '-'?Natural'.'Digit*;
        token Natural = Digit+;
            
        syntax Coeff= ',' c:Coefficient=>c|
            c:Coefficient=>c;
        syntax CoeffList= ':' c:Coeff+ =>c;
 
        syntax Seq = "Sequence" n:Natural=>n;
        
        syntax Samp = r:Seq s:CoeffList =>
            id(r) {valuesof(s)};
            
        syntax Samples = "Samples:" r:Natural=>r;
                
        interleave TokensIHate = " " | "\r" | "\n" | "\t";
    }
}